﻿


using System;
using System.Linq;
using System.Data.Linq;
using Csla;
using Csla.Data;
using Csla.Security;


namespace Kiosk.Library
{
	#region CellProvider
	[Serializable()]
	public partial class CellProvider : BusinessBase<CellProvider>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> CellProviderIDProperty = RegisterProperty<Guid>(typeof(CellProvider), new PropertyInfo<Guid>("CellProviderID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid CellProviderID
		{
		  get { return GetProperty<Guid>(CellProviderIDProperty); }
		}

		private static PropertyInfo<string> NameProperty = RegisterProperty<string>(typeof(CellProvider), new PropertyInfo<string>("Name"));
		public string Name
		{
		  get { return GetProperty<string>(NameProperty); }
		  set { SetProperty<string>(NameProperty, value); }
		}

		private static PropertyInfo<string> SmsGatewayProperty = RegisterProperty<string>(typeof(CellProvider), new PropertyInfo<string>("SmsGateway"));
		public string SmsGateway
		{
		  get { return GetProperty<string>(SmsGatewayProperty); }
		  set { SetProperty<string>(SmsGatewayProperty, value); }
		}

		public override string ToString()
		{
		  return CellProviderID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static CellProvider NewCellProvider()
		{
		  return DataPortal.Create<CellProvider>();
		}

		public static CellProvider GetCellProvider(Guid id)
		{
		  return DataPortal.Fetch<CellProvider>(new SingleCriteria<CellProvider, Guid>(id));
		}

		public static void DeleteCellProvider(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<CellProvider, Guid >(id));
		}

		private CellProvider()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(CellProviderIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<CellProvider, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get CellProvider data
			var data = (from o in ctx.DataContext.CellProvider
						where o.CellProviderID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(CellProviderIDProperty, data.CellProviderID);
									
			LoadProperty<string>(NameProperty, data.Name);
									
			LoadProperty<string>(SmsGatewayProperty, data.SmsGateway);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<CellProviderResources>(ResourcesProperty, CellProviderResources.GetCellProviderResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert CellProvider data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertCellProvider(
			
			  ReadProperty<Guid>(CellProviderIDProperty),
			
			  ReadProperty<string>(NameProperty),
			
			  ReadProperty<string>(SmsGatewayProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<CellProviderResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert CellProvider data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdateCellProvider(
			
			  ReadProperty<Guid>(CellProviderIDProperty),
			
			  ReadProperty<string>(NameProperty),
			
			  ReadProperty<string>(SmsGatewayProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<CellProviderResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<CellProvider, Guid>(ReadProperty<Guid>(CellProviderIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<CellProvider, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete CellProvider data
			ctx.DataContext.DeleteCellProvider(criteria.Value);
			// reset child list field
			//SetProperty<CellProviderResources>(ResourcesProperty, CellProviderResources.NewCellProviderResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool CellProviderExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.CellProviderExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.CellProvider
						  where o.CellProviderID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region Employee
	[Serializable()]
	public partial class Employee : BusinessBase<Employee>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> EmployeeIDProperty = RegisterProperty<Guid>(typeof(Employee), new PropertyInfo<Guid>("EmployeeID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid EmployeeID
		{
		  get { return GetProperty<Guid>(EmployeeIDProperty); }
		}

		private static PropertyInfo<string> DomainNameProperty = RegisterProperty<string>(typeof(Employee), new PropertyInfo<string>("DomainName"));
		public string DomainName
		{
		  get { return GetProperty<string>(DomainNameProperty); }
		  set { SetProperty<string>(DomainNameProperty, value); }
		}

		private static PropertyInfo<string> FirstNameProperty = RegisterProperty<string>(typeof(Employee), new PropertyInfo<string>("FirstName"));
		public string FirstName
		{
		  get { return GetProperty<string>(FirstNameProperty); }
		  set { SetProperty<string>(FirstNameProperty, value); }
		}

		private static PropertyInfo<string> LastNameProperty = RegisterProperty<string>(typeof(Employee), new PropertyInfo<string>("LastName"));
		public string LastName
		{
		  get { return GetProperty<string>(LastNameProperty); }
		  set { SetProperty<string>(LastNameProperty, value); }
		}

		private static PropertyInfo<Guid> LocationIDProperty = RegisterProperty<Guid>(typeof(Employee), new PropertyInfo<Guid>("LocationID"));
		public Guid LocationID
		{
		  get { return GetProperty<Guid>(LocationIDProperty); }
		  set { SetProperty<Guid>(LocationIDProperty, value); }
		}

		private static PropertyInfo<string> EmailProperty = RegisterProperty<string>(typeof(Employee), new PropertyInfo<string>("Email"));
		public string Email
		{
		  get { return GetProperty<string>(EmailProperty); }
		  set { SetProperty<string>(EmailProperty, value); }
		}

		private static PropertyInfo<string> OfficePhoneProperty = RegisterProperty<string>(typeof(Employee), new PropertyInfo<string>("OfficePhone"));
		public string OfficePhone
		{
		  get { return GetProperty<string>(OfficePhoneProperty); }
		  set { SetProperty<string>(OfficePhoneProperty, value); }
		}

		private static PropertyInfo<string> CellPhoneProperty = RegisterProperty<string>(typeof(Employee), new PropertyInfo<string>("CellPhone"));
		public string CellPhone
		{
		  get { return GetProperty<string>(CellPhoneProperty); }
		  set { SetProperty<string>(CellPhoneProperty, value); }
		}

		private static PropertyInfo<Guid> CellProviderIDProperty = RegisterProperty<Guid>(typeof(Employee), new PropertyInfo<Guid>("CellProviderID"));
		public Guid CellProviderID
		{
		  get { return GetProperty<Guid>(CellProviderIDProperty); }
		  set { SetProperty<Guid>(CellProviderIDProperty, value); }
		}

		public override string ToString()
		{
		  return EmployeeID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static Employee NewEmployee()
		{
		  return DataPortal.Create<Employee>();
		}

		public static Employee GetEmployee(Guid id)
		{
		  return DataPortal.Fetch<Employee>(new SingleCriteria<Employee, Guid>(id));
		}

		public static void DeleteEmployee(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<Employee, Guid >(id));
		}

		private Employee()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(EmployeeIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<Employee, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get Employee data
			var data = (from o in ctx.DataContext.Employee
						where o.EmployeeID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(EmployeeIDProperty, data.EmployeeID);
									
			LoadProperty<string>(DomainNameProperty, data.DomainName);
									
			LoadProperty<string>(FirstNameProperty, data.FirstName);
									
			LoadProperty<string>(LastNameProperty, data.LastName);
									
			LoadProperty<Guid>(LocationIDProperty, data.LocationID);
									
			LoadProperty<string>(EmailProperty, data.Email);
									
			LoadProperty<string>(OfficePhoneProperty, data.OfficePhone);
									
			LoadProperty<string>(CellPhoneProperty, data.CellPhone);
									
			LoadProperty<Guid>(CellProviderIDProperty, data.CellProviderID);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<EmployeeResources>(ResourcesProperty, EmployeeResources.GetEmployeeResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Employee data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertEmployee(
			
			  ReadProperty<Guid>(EmployeeIDProperty),
			
			  ReadProperty<string>(DomainNameProperty),
			
			  ReadProperty<string>(FirstNameProperty),
			
			  ReadProperty<string>(LastNameProperty),
			
			  ReadProperty<Guid>(LocationIDProperty),
			
			  ReadProperty<string>(EmailProperty),
			
			  ReadProperty<string>(OfficePhoneProperty),
			
			  ReadProperty<string>(CellPhoneProperty),
			
			  ReadProperty<Guid>(CellProviderIDProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<EmployeeResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Employee data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdateEmployee(
			
			  ReadProperty<Guid>(EmployeeIDProperty),
			
			  ReadProperty<string>(DomainNameProperty),
			
			  ReadProperty<string>(FirstNameProperty),
			
			  ReadProperty<string>(LastNameProperty),
			
			  ReadProperty<Guid>(LocationIDProperty),
			
			  ReadProperty<string>(EmailProperty),
			
			  ReadProperty<string>(OfficePhoneProperty),
			
			  ReadProperty<string>(CellPhoneProperty),
			
			  ReadProperty<Guid>(CellProviderIDProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<EmployeeResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<Employee, Guid>(ReadProperty<Guid>(EmployeeIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<Employee, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete Employee data
			ctx.DataContext.DeleteEmployee(criteria.Value);
			// reset child list field
			//SetProperty<EmployeeResources>(ResourcesProperty, EmployeeResources.NewEmployeeResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool EmployeeExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.EmployeeExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.Employee
						  where o.EmployeeID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region Icon
	[Serializable()]
	public partial class Icon : BusinessBase<Icon>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> IconIDProperty = RegisterProperty<Guid>(typeof(Icon), new PropertyInfo<Guid>("IconID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid IconID
		{
		  get { return GetProperty<Guid>(IconIDProperty); }
		}

		private static PropertyInfo<string> IconFileProperty = RegisterProperty<string>(typeof(Icon), new PropertyInfo<string>("IconFile"));
		public string IconFile
		{
		  get { return GetProperty<string>(IconFileProperty); }
		  set { SetProperty<string>(IconFileProperty, value); }
		}

		private static PropertyInfo<string> IconKeywordProperty = RegisterProperty<string>(typeof(Icon), new PropertyInfo<string>("IconKeyword"));
		public string IconKeyword
		{
		  get { return GetProperty<string>(IconKeywordProperty); }
		  set { SetProperty<string>(IconKeywordProperty, value); }
		}

		public override string ToString()
		{
		  return IconID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static Icon NewIcon()
		{
		  return DataPortal.Create<Icon>();
		}

		public static Icon GetIcon(Guid id)
		{
		  return DataPortal.Fetch<Icon>(new SingleCriteria<Icon, Guid>(id));
		}

		public static void DeleteIcon(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<Icon, Guid >(id));
		}

		private Icon()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(IconIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<Icon, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get Icon data
			var data = (from o in ctx.DataContext.Icon
						where o.IconID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(IconIDProperty, data.IconID);
									
			LoadProperty<string>(IconFileProperty, data.IconFile);
									
			LoadProperty<string>(IconKeywordProperty, data.IconKeyword);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<IconResources>(ResourcesProperty, IconResources.GetIconResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Icon data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertIcon(
			
			  ReadProperty<Guid>(IconIDProperty),
			
			  ReadProperty<string>(IconFileProperty),
			
			  ReadProperty<string>(IconKeywordProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<IconResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Icon data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdateIcon(
			
			  ReadProperty<Guid>(IconIDProperty),
			
			  ReadProperty<string>(IconFileProperty),
			
			  ReadProperty<string>(IconKeywordProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<IconResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<Icon, Guid>(ReadProperty<Guid>(IconIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<Icon, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete Icon data
			ctx.DataContext.DeleteIcon(criteria.Value);
			// reset child list field
			//SetProperty<IconResources>(ResourcesProperty, IconResources.NewIconResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool IconExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.IconExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.Icon
						  where o.IconID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region Location
	[Serializable()]
	public partial class Location : BusinessBase<Location>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> LocationIDProperty = RegisterProperty<Guid>(typeof(Location), new PropertyInfo<Guid>("LocationID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid LocationID
		{
		  get { return GetProperty<Guid>(LocationIDProperty); }
		}

		private static PropertyInfo<string> NameProperty = RegisterProperty<string>(typeof(Location), new PropertyInfo<string>("Name"));
		public string Name
		{
		  get { return GetProperty<string>(NameProperty); }
		  set { SetProperty<string>(NameProperty, value); }
		}

		private static PropertyInfo<int> XCoordinateProperty = RegisterProperty<int>(typeof(Location), new PropertyInfo<int>("XCoordinate"));
		public int XCoordinate
		{
		  get { return GetProperty<int>(XCoordinateProperty); }
		  set { SetProperty<int>(XCoordinateProperty, value); }
		}

		private static PropertyInfo<int> YCoordinateProperty = RegisterProperty<int>(typeof(Location), new PropertyInfo<int>("YCoordinate"));
		public int YCoordinate
		{
		  get { return GetProperty<int>(YCoordinateProperty); }
		  set { SetProperty<int>(YCoordinateProperty, value); }
		}

		public override string ToString()
		{
		  return LocationID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static Location NewLocation()
		{
		  return DataPortal.Create<Location>();
		}

		public static Location GetLocation(Guid id)
		{
		  return DataPortal.Fetch<Location>(new SingleCriteria<Location, Guid>(id));
		}

		public static void DeleteLocation(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<Location, Guid >(id));
		}

		private Location()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(LocationIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<Location, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get Location data
			var data = (from o in ctx.DataContext.Location
						where o.LocationID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(LocationIDProperty, data.LocationID);
									
			LoadProperty<string>(NameProperty, data.Name);
									
			LoadProperty<int>(XCoordinateProperty, data.XCoordinate);
									
			LoadProperty<int>(YCoordinateProperty, data.YCoordinate);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<LocationResources>(ResourcesProperty, LocationResources.GetLocationResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Location data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertLocation(
			
			  ReadProperty<Guid>(LocationIDProperty),
			
			  ReadProperty<string>(NameProperty),
			
			  ReadProperty<int>(XCoordinateProperty),
			
			  ReadProperty<int>(YCoordinateProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<LocationResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Location data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdateLocation(
			
			  ReadProperty<Guid>(LocationIDProperty),
			
			  ReadProperty<string>(NameProperty),
			
			  ReadProperty<int>(XCoordinateProperty),
			
			  ReadProperty<int>(YCoordinateProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<LocationResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<Location, Guid>(ReadProperty<Guid>(LocationIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<Location, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete Location data
			ctx.DataContext.DeleteLocation(criteria.Value);
			// reset child list field
			//SetProperty<LocationResources>(ResourcesProperty, LocationResources.NewLocationResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool LocationExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.LocationExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.Location
						  where o.LocationID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region Notification
	[Serializable()]
	public partial class Notification : BusinessBase<Notification>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> NotificationIDProperty = RegisterProperty<Guid>(typeof(Notification), new PropertyInfo<Guid>("NotificationID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid NotificationID
		{
		  get { return GetProperty<Guid>(NotificationIDProperty); }
		}

		private static PropertyInfo<Guid> NotificationTypeIDProperty = RegisterProperty<Guid>(typeof(Notification), new PropertyInfo<Guid>("NotificationTypeID"));
		public Guid NotificationTypeID
		{
		  get { return GetProperty<Guid>(NotificationTypeIDProperty); }
		  set { SetProperty<Guid>(NotificationTypeIDProperty, value); }
		}

		private static PropertyInfo<Guid> LocationIDProperty = RegisterProperty<Guid>(typeof(Notification), new PropertyInfo<Guid>("LocationID"));
		public Guid LocationID
		{
		  get { return GetProperty<Guid>(LocationIDProperty); }
		  set { SetProperty<Guid>(LocationIDProperty, value); }
		}

		private static PropertyInfo<Guid> EmployeeIDProperty = RegisterProperty<Guid>(typeof(Notification), new PropertyInfo<Guid>("EmployeeID"));
		public Guid EmployeeID
		{
		  get { return GetProperty<Guid>(EmployeeIDProperty); }
		  set { SetProperty<Guid>(EmployeeIDProperty, value); }
		}

		private static PropertyInfo<DateTime?> NotificationDateProperty = RegisterProperty<DateTime?>(typeof(Notification), new PropertyInfo<DateTime?>("NotificationDate"));
		public DateTime? NotificationDate
		{
		  get { return GetProperty<DateTime?>(NotificationDateProperty); }
		  set { SetProperty<DateTime?>(NotificationDateProperty, value); }
		}

		private static PropertyInfo<string> TitleProperty = RegisterProperty<string>(typeof(Notification), new PropertyInfo<string>("Title"));
		public string Title
		{
		  get { return GetProperty<string>(TitleProperty); }
		  set { SetProperty<string>(TitleProperty, value); }
		}

		private static PropertyInfo<string> DescriptionProperty = RegisterProperty<string>(typeof(Notification), new PropertyInfo<string>("Description"));
		public string Description
		{
		  get { return GetProperty<string>(DescriptionProperty); }
		  set { SetProperty<string>(DescriptionProperty, value); }
		}

		public override string ToString()
		{
		  return NotificationID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static Notification NewNotification()
		{
		  return DataPortal.Create<Notification>();
		}

		public static Notification GetNotification(Guid id)
		{
		  return DataPortal.Fetch<Notification>(new SingleCriteria<Notification, Guid>(id));
		}

		public static void DeleteNotification(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<Notification, Guid >(id));
		}

		private Notification()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(NotificationIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<Notification, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get Notification data
			var data = (from o in ctx.DataContext.Notification
						where o.NotificationID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(NotificationIDProperty, data.NotificationID);
									
			LoadProperty<Guid>(NotificationTypeIDProperty, data.NotificationTypeID);
									
			LoadProperty<Guid>(LocationIDProperty, data.LocationID);
									
			LoadProperty<Guid>(EmployeeIDProperty, data.EmployeeID);
									
			LoadProperty<DateTime?>(NotificationDateProperty, data.NotificationDate);
									
			LoadProperty<string>(TitleProperty, data.Title);
									
			LoadProperty<string>(DescriptionProperty, data.Description);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<NotificationResources>(ResourcesProperty, NotificationResources.GetNotificationResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Notification data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertNotification(
			
			  ReadProperty<Guid>(NotificationIDProperty),
			
			  ReadProperty<Guid>(NotificationTypeIDProperty),
			
			  ReadProperty<Guid>(LocationIDProperty),
			
			  ReadProperty<Guid>(EmployeeIDProperty),
			
			  ReadProperty<DateTime?>(NotificationDateProperty),
			
			  ReadProperty<string>(TitleProperty),
			
			  ReadProperty<string>(DescriptionProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<NotificationResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Notification data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdateNotification(
			
			  ReadProperty<Guid>(NotificationIDProperty),
			
			  ReadProperty<Guid>(NotificationTypeIDProperty),
			
			  ReadProperty<Guid>(LocationIDProperty),
			
			  ReadProperty<Guid>(EmployeeIDProperty),
			
			  ReadProperty<DateTime?>(NotificationDateProperty),
			
			  ReadProperty<string>(TitleProperty),
			
			  ReadProperty<string>(DescriptionProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<NotificationResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<Notification, Guid>(ReadProperty<Guid>(NotificationIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<Notification, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete Notification data
			ctx.DataContext.DeleteNotification(criteria.Value);
			// reset child list field
			//SetProperty<NotificationResources>(ResourcesProperty, NotificationResources.NewNotificationResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool NotificationExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.NotificationExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.Notification
						  where o.NotificationID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region NotificationType
	[Serializable()]
	public partial class NotificationType : BusinessBase<NotificationType>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> NotificationTypeIDProperty = RegisterProperty<Guid>(typeof(NotificationType), new PropertyInfo<Guid>("NotificationTypeID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid NotificationTypeID
		{
		  get { return GetProperty<Guid>(NotificationTypeIDProperty); }
		}

		private static PropertyInfo<string> NameProperty = RegisterProperty<string>(typeof(NotificationType), new PropertyInfo<string>("Name"));
		public string Name
		{
		  get { return GetProperty<string>(NameProperty); }
		  set { SetProperty<string>(NameProperty, value); }
		}

		public override string ToString()
		{
		  return NotificationTypeID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static NotificationType NewNotificationType()
		{
		  return DataPortal.Create<NotificationType>();
		}

		public static NotificationType GetNotificationType(Guid id)
		{
		  return DataPortal.Fetch<NotificationType>(new SingleCriteria<NotificationType, Guid>(id));
		}

		public static void DeleteNotificationType(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<NotificationType, Guid >(id));
		}

		private NotificationType()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(NotificationTypeIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<NotificationType, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get NotificationType data
			var data = (from o in ctx.DataContext.NotificationType
						where o.NotificationTypeID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(NotificationTypeIDProperty, data.NotificationTypeID);
									
			LoadProperty<string>(NameProperty, data.Name);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<NotificationTypeResources>(ResourcesProperty, NotificationTypeResources.GetNotificationTypeResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert NotificationType data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertNotificationType(
			
			  ReadProperty<Guid>(NotificationTypeIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<NotificationTypeResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert NotificationType data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdateNotificationType(
			
			  ReadProperty<Guid>(NotificationTypeIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<NotificationTypeResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<NotificationType, Guid>(ReadProperty<Guid>(NotificationTypeIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<NotificationType, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete NotificationType data
			ctx.DataContext.DeleteNotificationType(criteria.Value);
			// reset child list field
			//SetProperty<NotificationTypeResources>(ResourcesProperty, NotificationTypeResources.NewNotificationTypeResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool NotificationTypeExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.NotificationTypeExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.NotificationType
						  where o.NotificationTypeID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region Presentation
	[Serializable()]
	public partial class Presentation : BusinessBase<Presentation>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> PresentationIDProperty = RegisterProperty<Guid>(typeof(Presentation), new PropertyInfo<Guid>("PresentationID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid PresentationID
		{
		  get { return GetProperty<Guid>(PresentationIDProperty); }
		}

		private static PropertyInfo<Guid> PresentationTypeIDProperty = RegisterProperty<Guid>(typeof(Presentation), new PropertyInfo<Guid>("PresentationTypeID"));
		public Guid PresentationTypeID
		{
		  get { return GetProperty<Guid>(PresentationTypeIDProperty); }
		  set { SetProperty<Guid>(PresentationTypeIDProperty, value); }
		}

		private static PropertyInfo<Guid> PresentationStatusIDProperty = RegisterProperty<Guid>(typeof(Presentation), new PropertyInfo<Guid>("PresentationStatusID"));
		public Guid PresentationStatusID
		{
		  get { return GetProperty<Guid>(PresentationStatusIDProperty); }
		  set { SetProperty<Guid>(PresentationStatusIDProperty, value); }
		}

		private static PropertyInfo<string> NameProperty = RegisterProperty<string>(typeof(Presentation), new PropertyInfo<string>("Name"));
		public string Name
		{
		  get { return GetProperty<string>(NameProperty); }
		  set { SetProperty<string>(NameProperty, value); }
		}

		public override string ToString()
		{
		  return PresentationID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static Presentation NewPresentation()
		{
		  return DataPortal.Create<Presentation>();
		}

		public static Presentation GetPresentation(Guid id)
		{
		  return DataPortal.Fetch<Presentation>(new SingleCriteria<Presentation, Guid>(id));
		}

		public static void DeletePresentation(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<Presentation, Guid >(id));
		}

		private Presentation()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(PresentationIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<Presentation, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get Presentation data
			var data = (from o in ctx.DataContext.Presentation
						where o.PresentationID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(PresentationIDProperty, data.PresentationID);
									
			LoadProperty<Guid>(PresentationTypeIDProperty, data.PresentationTypeID);
									
			LoadProperty<Guid>(PresentationStatusIDProperty, data.PresentationStatusID);
									
			LoadProperty<string>(NameProperty, data.Name);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<PresentationResources>(ResourcesProperty, PresentationResources.GetPresentationResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Presentation data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertPresentation(
			
			  ReadProperty<Guid>(PresentationIDProperty),
			
			  ReadProperty<Guid>(PresentationTypeIDProperty),
			
			  ReadProperty<Guid>(PresentationStatusIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<PresentationResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Presentation data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdatePresentation(
			
			  ReadProperty<Guid>(PresentationIDProperty),
			
			  ReadProperty<Guid>(PresentationTypeIDProperty),
			
			  ReadProperty<Guid>(PresentationStatusIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<PresentationResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<Presentation, Guid>(ReadProperty<Guid>(PresentationIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<Presentation, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete Presentation data
			ctx.DataContext.DeletePresentation(criteria.Value);
			// reset child list field
			//SetProperty<PresentationResources>(ResourcesProperty, PresentationResources.NewPresentationResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool PresentationExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.PresentationExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.Presentation
						  where o.PresentationID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region PresentationStatus
	[Serializable()]
	public partial class PresentationStatus : BusinessBase<PresentationStatus>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> PresentationStatusIDProperty = RegisterProperty<Guid>(typeof(PresentationStatus), new PropertyInfo<Guid>("PresentationStatusID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid PresentationStatusID
		{
		  get { return GetProperty<Guid>(PresentationStatusIDProperty); }
		}

		private static PropertyInfo<string> NameProperty = RegisterProperty<string>(typeof(PresentationStatus), new PropertyInfo<string>("Name"));
		public string Name
		{
		  get { return GetProperty<string>(NameProperty); }
		  set { SetProperty<string>(NameProperty, value); }
		}

		public override string ToString()
		{
		  return PresentationStatusID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static PresentationStatus NewPresentationStatus()
		{
		  return DataPortal.Create<PresentationStatus>();
		}

		public static PresentationStatus GetPresentationStatus(Guid id)
		{
		  return DataPortal.Fetch<PresentationStatus>(new SingleCriteria<PresentationStatus, Guid>(id));
		}

		public static void DeletePresentationStatus(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<PresentationStatus, Guid >(id));
		}

		private PresentationStatus()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(PresentationStatusIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<PresentationStatus, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get PresentationStatus data
			var data = (from o in ctx.DataContext.PresentationStatus
						where o.PresentationStatusID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(PresentationStatusIDProperty, data.PresentationStatusID);
									
			LoadProperty<string>(NameProperty, data.Name);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<PresentationStatusResources>(ResourcesProperty, PresentationStatusResources.GetPresentationStatusResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert PresentationStatus data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertPresentationStatus(
			
			  ReadProperty<Guid>(PresentationStatusIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<PresentationStatusResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert PresentationStatus data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdatePresentationStatus(
			
			  ReadProperty<Guid>(PresentationStatusIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<PresentationStatusResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<PresentationStatus, Guid>(ReadProperty<Guid>(PresentationStatusIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<PresentationStatus, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete PresentationStatus data
			ctx.DataContext.DeletePresentationStatus(criteria.Value);
			// reset child list field
			//SetProperty<PresentationStatusResources>(ResourcesProperty, PresentationStatusResources.NewPresentationStatusResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool PresentationStatusExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.PresentationStatusExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.PresentationStatus
						  where o.PresentationStatusID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region PresentationType
	[Serializable()]
	public partial class PresentationType : BusinessBase<PresentationType>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> PresentationTypeIDProperty = RegisterProperty<Guid>(typeof(PresentationType), new PropertyInfo<Guid>("PresentationTypeID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid PresentationTypeID
		{
		  get { return GetProperty<Guid>(PresentationTypeIDProperty); }
		}

		private static PropertyInfo<string> NameProperty = RegisterProperty<string>(typeof(PresentationType), new PropertyInfo<string>("Name"));
		public string Name
		{
		  get { return GetProperty<string>(NameProperty); }
		  set { SetProperty<string>(NameProperty, value); }
		}

		public override string ToString()
		{
		  return PresentationTypeID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static PresentationType NewPresentationType()
		{
		  return DataPortal.Create<PresentationType>();
		}

		public static PresentationType GetPresentationType(Guid id)
		{
		  return DataPortal.Fetch<PresentationType>(new SingleCriteria<PresentationType, Guid>(id));
		}

		public static void DeletePresentationType(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<PresentationType, Guid >(id));
		}

		private PresentationType()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(PresentationTypeIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<PresentationType, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get PresentationType data
			var data = (from o in ctx.DataContext.PresentationType
						where o.PresentationTypeID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(PresentationTypeIDProperty, data.PresentationTypeID);
									
			LoadProperty<string>(NameProperty, data.Name);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<PresentationTypeResources>(ResourcesProperty, PresentationTypeResources.GetPresentationTypeResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert PresentationType data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertPresentationType(
			
			  ReadProperty<Guid>(PresentationTypeIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<PresentationTypeResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert PresentationType data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdatePresentationType(
			
			  ReadProperty<Guid>(PresentationTypeIDProperty),
			
			  ReadProperty<string>(NameProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<PresentationTypeResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<PresentationType, Guid>(ReadProperty<Guid>(PresentationTypeIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<PresentationType, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete PresentationType data
			ctx.DataContext.DeletePresentationType(criteria.Value);
			// reset child list field
			//SetProperty<PresentationTypeResources>(ResourcesProperty, PresentationTypeResources.NewPresentationTypeResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool PresentationTypeExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.PresentationTypeExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.PresentationType
						  where o.PresentationTypeID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
	#region Slide
	[Serializable()]
	public partial class Slide : BusinessBase<Slide>
	{
		#region  Business Methods

		private byte[] mTimestamp = new byte[8];
		
		// Primary Key
		private static PropertyInfo<Guid> SlideIDProperty = RegisterProperty<Guid>(typeof(Slide), new PropertyInfo<Guid>("SlideID"));
		[System.ComponentModel.DataObjectField(true, true)]
		public Guid SlideID
		{
		  get { return GetProperty<Guid>(SlideIDProperty); }
		}

		private static PropertyInfo<Guid> PresentationIDProperty = RegisterProperty<Guid>(typeof(Slide), new PropertyInfo<Guid>("PresentationID"));
		public Guid PresentationID
		{
		  get { return GetProperty<Guid>(PresentationIDProperty); }
		  set { SetProperty<Guid>(PresentationIDProperty, value); }
		}

		private static PropertyInfo<string> TitleProperty = RegisterProperty<string>(typeof(Slide), new PropertyInfo<string>("Title"));
		public string Title
		{
		  get { return GetProperty<string>(TitleProperty); }
		  set { SetProperty<string>(TitleProperty, value); }
		}

		private static PropertyInfo<string> LocationProperty = RegisterProperty<string>(typeof(Slide), new PropertyInfo<string>("Location"));
		public string Location
		{
		  get { return GetProperty<string>(LocationProperty); }
		  set { SetProperty<string>(LocationProperty, value); }
		}

		private static PropertyInfo<int> OrderProperty = RegisterProperty<int>(typeof(Slide), new PropertyInfo<int>("Order"));
		public int Order
		{
		  get { return GetProperty<int>(OrderProperty); }
		  set { SetProperty<int>(OrderProperty, value); }
		}

		public override string ToString()
		{
		  return SlideID.ToString();
		}

		#endregion

		#region  Factory Methods

		public static Slide NewSlide()
		{
		  return DataPortal.Create<Slide>();
		}

		public static Slide GetSlide(Guid id)
		{
		  return DataPortal.Fetch<Slide>(new SingleCriteria<Slide, Guid>(id));
		}

		public static void DeleteSlide(Guid  id)
		{
		  DataPortal.Delete(new SingleCriteria<Slide, Guid >(id));
		}

		private Slide()
		{ /* require use of factory methods */ }

		#endregion

		#region  Data Access

		[RunLocal()]
		protected override void DataPortal_Create()
		{
		  LoadProperty<Guid>(SlideIDProperty, Guid.NewGuid());
		  ValidationRules.CheckRules();
		}

		private void DataPortal_Fetch(SingleCriteria<Slide, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// get Slide data
			var data = (from o in ctx.DataContext.Slide
						where o.SlideID  == criteria.Value
						select o).Single();
									
			LoadProperty<Guid>(SlideIDProperty, data.SlideID);
									
			LoadProperty<Guid>(PresentationIDProperty, data.PresentationID);
									
			LoadProperty<string>(TitleProperty, data.Title);
									
			LoadProperty<string>(LocationProperty, data.Location);
									
			LoadProperty<int>(OrderProperty, data.Order);
			//LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);			
			mTimestamp = data.Timestamp.ToArray();

			// get child data
//			LoadProperty<SlideResources>(ResourcesProperty, SlideResources.GetSlideResources(data.Assignments.ToArray()));
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Insert()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Slide data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.InsertSlide(
			
			  ReadProperty<Guid>(SlideIDProperty),
			
			  ReadProperty<Guid>(PresentationIDProperty),
			
			  ReadProperty<string>(TitleProperty),
			
			  ReadProperty<string>(LocationProperty),
			
			  ReadProperty<int>(OrderProperty),
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
//			DataPortal.UpdateChild(ReadProperty<SlideResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_Update()
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// insert Slide data
			System.Data.Linq.Binary lastChanged = null;
			ctx.DataContext.UpdateSlide(
			
			  ReadProperty<Guid>(SlideIDProperty),
			
			  ReadProperty<Guid>(PresentationIDProperty),
			
			  ReadProperty<string>(TitleProperty),
			
			  ReadProperty<string>(LocationProperty),
			
			  ReadProperty<int>(OrderProperty),
			  mTimestamp,
			  ref lastChanged);
			mTimestamp = lastChanged.ToArray();
			// update child objects
			//DataPortal.UpdateChild(ReadProperty<SlideResources>(ResourcesProperty), this);
		  }
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		protected override void DataPortal_DeleteSelf()
		{
		  DataPortal_Delete(new SingleCriteria<Slide, Guid>(ReadProperty<Guid>(SlideIDProperty)));
		}

		[Transactional(TransactionalTypes.TransactionScope)]
		private void DataPortal_Delete(SingleCriteria<Slide, Guid> criteria)
		{
		  using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
		  {
			// delete Slide data
			ctx.DataContext.DeleteSlide(criteria.Value);
			// reset child list field
			//SetProperty<SlideResources>(ResourcesProperty, SlideResources.NewSlideResources());
		  }
		}

		#endregion

		#region  Exists

		public static bool Exists(Guid id)
		{
		  return ExistsCommand.Exists(id);
		}

		[Serializable()]
		private class ExistsCommand : CommandBase
		{
		  private Guid _id;
		  private bool _exists;

		  public bool SlideExists
		  {
			get { return _exists; }
		  }

		  public static bool Exists(Guid id)
		  {
			ExistsCommand result = null;
			result = DataPortal.Execute<ExistsCommand>(new ExistsCommand(id));
			return result.SlideExists;
		  }

		  private ExistsCommand(Guid id)
		  {
			_id = id;
		  }

		  protected override void DataPortal_Execute()
		  {
			using (var ctx = ContextManager<Kiosk.Data.KioskDataContext>.GetManager(Database.ConnectionString))
			{
			  _exists = ((from o in ctx.DataContext.Slide
						  where o.SlideID == _id
						  select o).Count() > 0);
			}
		  }
		}

		#endregion
	}
	#endregion
	
}

